package com.petAdoption.manager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.petAdoption.manager.dto.EmployeeDto;
import com.petAdoption.manager.entity.Employee;
import com.petAdoption.manager.entity.Examineneck;
import com.petAdoption.manager.mapper.EmployeeMapper;
import com.petAdoption.manager.mapper.ExamineneckMapper;
import com.petAdoption.manager.service.IEmployeeService;
import com.petAdoption.manager.util.TokenUtil;
import com.petAdoption.manager.vo.EmployeeInfoVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {
    @Resource
    private EmployeeMapper employeeMapper;


    @Override
    public Employee login(EmployeeDto dto) {
        QueryWrapper<Employee> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("employee_username",dto.getUsername()).eq("employee_password",dto.getPassword());
        return employeeMapper.selectOne(queryWrapper);
    }


    @Override
    public int updateEmployee(Employee employee) {
        return employeeMapper.updateById(employee);
    }

    @Override
    public Employee get(Employee employee){
        return employeeMapper.selectById(employee.getEmployeeId());
    }

    @Override
    public Employee findEmployee(Employee employee) {
        return employeeMapper.selectOne(new QueryWrapper<Employee>().eq("employee_username",employee.getEmployeeUsername()));
    }

//    @Override
//    public Employee regexUsername(String username) {
//        return employeeMapper.regexUsername(username);
//    }


}
